# -- coding: utf-8 --
import logging

from flask import Flask, request
from flask_restful import Api

from resources.calendar import Calendar
from resources.metro import Metro
from resources.translate import Translate
from resources.poem import Poem
from resources.ip import Ip

from resources.upload import Upload
from resources.autohome import Autohome

logging.basicConfig(level=logging.DEBUG,
                    format='%(asctime)s %(levelname)s %(message)s')
logger = logging.getLogger(__name__)

app = Flask(__name__)
api = Api(app)

##
## Actually setup the Api resource routing here
##
api.add_resource(Translate, '/translate')
api.add_resource(Calendar, '/calendar')
api.add_resource(Metro, '/metro/<todo>')
api.add_resource(Poem, '/poem')
api.add_resource(Ip, '/ip')
api.add_resource(Upload, '/upload')
api.add_resource(Autohome, '/autohome/<todo>')


# api.add_resource(Todo, '/todos/<todo_id>')

# sched = BackgroundScheduler()
# sched.add_job(CrawlerMetro().start_crawler, 'date', run_date='2018-10-24 18:21:55')
# sched.add_job(CrawlerMetro().start_crawler, 'cron', hour=2, minute=0, second=0)
# sched.start()

@app.route('/')
def hello_world():
    return "Hello World"


if __name__ == '__main__':
    app.run(host='127.0.0.1', port=5000)
